package com.gcc.dao.impl;

import com.gcc.dao.OrderItemDao;
import com.gcc.pojo.OrderItem;

import java.util.List;

public class OrderItemDaoImpl extends BaseDao implements OrderItemDao {
    @Override
    public int saveOrderItem(OrderItem orderItem) {
        String sql="insert into t_order_item(`name`,`count`,price,total_price,order_id) value(?,?,?,?,?)";
        return update(sql,orderItem.getName(),orderItem.getCount(),orderItem.getPrice(),orderItem.getTotalPrice(),orderItem.getOrderId());
    }

    @Override
    public List<OrderItem> queryOrderItemByOrderId(String orderId) {
        String sql="select id as id,`name` as `name`,`count` as `count`,price as price,total_price as totalPrice,order_id as orderId from t_order_item where order_id=?";
        return querYForList(OrderItem.class,sql,orderId);
    }
}
